package day0910.demo1;

import day0910.demo1.Animal;
import day0910.demo1.Cat;
import day0910.demo1.Dog;

/**
 * @Author:galaxy_yan
 * @Date: 2022/9/10
 * @Time: 17:16
 * @Description
 */
public class Text2 {
    public static void main(String[] args) {
        Cat cat=new Cat("blue",1);
        Dog dog=new Dog("元宝",3);

        Animal animal=cat;
        animal.eat();
        animal=dog;
        animal.eat();

        if(animal instanceof Cat){
            cat=(Cat)animal;
            cat.mew();
        }

        if(animal instanceof Dog) {
            dog = (Dog) animal;
            dog.back();
        }
    }
}
